package com.wwp.tbshop.activity.cartactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.wwp.tbshop.R;
import com.wwp.tbshop.activity.PayMentActivity;
import com.wwp.tbshop.model.bean.OrderSubmitResponseBean;
import com.wwp.tbshop.presenter.CommitPresenter;
import com.wwp.tbshop.util.PriceFormater;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by windows on 2017/6/15.
 */

public class CommitActivity extends Activity {
    @Bind(R.id.ib_shopcart_back)
    ImageButton mIbShopcartBack;
    @Bind(R.id.orderId)
    TextView mOrderId;
    @Bind(R.id.price)
    TextView mPrice;
    @Bind(R.id.paymentType)
    TextView mPaymentType;
    @Bind(R.id.order_detail)
    TextView mOrderDetail;
    private String mUserId;
    private Intent mIntent;

    private String mOrderID;
    public CommitPresenter mCommitPresenter;
    private CommitPresenter mCommitPresenter1;

    private float mTotalPriced;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_commit_successful);
        ButterKnife.bind(this);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        String sku = bundle.getString("sku");
        String addressId = bundle.getString("addressId");
        String paymentType = bundle.getString("paymentType");
        String deliveryType = bundle.getString("deliveryType");
        String invoiceType = bundle.getString("invoiceType");
        String invoiceTitle = bundle.getString("invoiceTitle");
        String invoiceContent = bundle.getString("invoiceContent");
        mTotalPriced = bundle.getFloat("totalPriced");

        mCommitPresenter1 = new CommitPresenter(sku, addressId, paymentType, deliveryType, invoiceType, invoiceTitle, invoiceContent, this);

    }



    @OnClick({R.id.ib_shopcart_back, R.id.order_detail})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ib_shopcart_back:
                finish();
                break;
            case R.id.order_detail:
                Intent intent = new Intent(this, PayMentActivity.class);
                startActivity(intent);
                break;
        }
    }


    public void CommitSuceess(OrderSubmitResponseBean orderSubmitResponseBean) {

        OrderSubmitResponseBean.OrderInfoBean orderInfo = orderSubmitResponseBean.getOrderInfo();
        mOrderID = orderInfo.getOrderId();

        float totalPrice = (float) 0.0;
        String orderId = orderInfo.getOrderId();
        int price = orderInfo.getPrice();
        int paymentType = orderInfo.getPaymentType();
        mOrderId.setText("您的订单号:" + orderId);
        mPrice.setText("应付的金额：" + PriceFormater.format(mTotalPriced));
        mPaymentType.setText("支付方式:" + paymentType);

    }
}
